package com.woniu.gf.pawn.management.controller;


import com.woniu.gf.pawn.comm.core.domain.PermissionCategory;
import com.woniu.gf.pawn.comm.core.dto.ResultDto;
import com.woniu.gf.pawn.management.dto.PermissionCategoryDto;
import com.woniu.gf.pawn.management.service.PermissionCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2020-10-13
 */
@RestController
@RequestMapping("/permission-category")
@CrossOrigin
@Api(tags = "权限类别")
public class PermissionCategoryController {
    @Autowired
    private PermissionCategoryService permissionCategoryService;
    @GetMapping("selectPermissionCategoryType")
    @ApiOperation("权限类别查询")
    public ResultDto selectPermissionCategoryType(){
        List<PermissionCategory> categoryList=permissionCategoryService.selectPermissionCategoryType();
        List<PermissionCategoryDto> categoryDtoList=new ArrayList<>();
        for (PermissionCategory permissionCategory:categoryList){
            PermissionCategoryDto permissionCategoryDto = new PermissionCategoryDto();
            BeanUtils.copyProperties(permissionCategory,permissionCategoryDto);
            categoryDtoList.add(permissionCategoryDto);
        }
        return ResultDto.success(200,"查询权限种类成功",categoryDtoList);
    }

}

